package com.jekun.helloworld.designmode.command.demo02;

/**
 * @author 智刚
 * @data : 2022/10/20 21:20
 * @des ：
 */
public class MultiplyCommand extends AbstractCommand{

	Multiply multiply = new Multiply();
	private int value;

	/**
	 * 执行
	 *
	 * @param value
	 * @return
	 */
	@Override
	public int execute(int value) {
		this.value = value;
		return multiply.mul(value);
	}

	/**
	 * 撤销
	 *
	 * @return
	 */
	@Override
	public int undo() {
		int i = multiply.getNum() / value;
		multiply.setNum(i);
		return i;
	}
}
